const PageViewStatisticsModel = require('../../model/PageViewStatisticsModel')
const {getTodayDate} = require('../../utils/getTodayDate')
const db = require('../../config/db')
const {QueryTypes} = require("sequelize");

class DataStatistics {
    //添加
    async getUserIpLocation(ip, location) {
        const addData = {
            ip_location: ip,
            location: location,
            create_date: getTodayDate()
        }
        const data = await PageViewStatisticsModel.create(addData)
        return data
    }


    //查询
    async getData(whereDate) {
        const sql = `SELECT * FROM page_view_statistics WHERE create_date='${whereDate}'`
        const data = await db.query(sql, {type: QueryTypes.SELECT})
        return data
    }
}


module.exports = new DataStatistics()
